/*
Copyright 2007 Raymond Giorgi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */

package edu.pitt.CS2510.Messages;

import java.util.ArrayList;

import edu.pitt.CS2510.Coordinate;
import edu.pitt.CS2510.Nodes.Node;

/**
 * 
 * @author NoOne
 * 
 *         Sent from either the Central to a Supervisor or from a Supervisor to
 *         the Central when the grid changes
 */
public class UpdateGridMessage extends Message {
	ArrayList<Coordinate> updates;

	/**
	 * Updates is a list of coordinates whos status has changed
	 * 
	 * @param to
	 * @param from
	 * @param updates
	 */
	public UpdateGridMessage(int to, int from, ArrayList<Coordinate> updates) {
		super(to, from);
		this.updates = updates;
	}

	/**
	 * Calls either the Central or Supervisor's processUpdateMessage() method
	 */
	@Override
	public void processMessage(Node node) {
		if (node.getMessageHandler() != null) {
			node.getMessageHandler().processUpdateMessage(updates, from);
		}
	}
}
